<template>
    <div class="inherit">
        <div class="inherit-top mb-20">
            <Breadcrumb router />
            <div class="row f f-ac">
                <div class="row-title">检索：</div>
                <div class="f-1">
                    <el-input v-model="queryForm.search" placeholder="输入关键词" size="small" clearable
                        style="width: 408px" @change="search" />
                </div>
            </div>
        </div>
        <div class="inherit-bottom">
            <div class="inherit-box f f-js f-w">
                <div class="person-item mb-30" v-for="(i, k) in dataList" :key="k" @click="handleDetail(i)">
                    <img :src="baseUrl + i.image" class="photo" />
                    <div class="person-bg">
                        <div class="person-name line-1">{{ i.title || "-" }}</div>
                        <div class="person-describe line-3">{{ i.msg || "-" }}</div>
                    </div>
                </div>
            </div>
            <Page-tool :size="queryForm.pageSize" :page="queryForm.currentPage" :total="total"
                @change-page="changePage" />
        </div>
    </div>
</template>

<script>
    import {
        heritageList
    } from "@/utils/heritage/index.js";
    export default {
        data() {
            return {
                baseUrl: process.env.VUE_APP_BASE_API,
                queryForm: {
                    search: "", // 搜索关键词
                    pageSize: 12, // 条数
                    currentPage: 1, // 页数
                },
                total: 0, // 总数
                dataList: [],
            };
        },

        mounted() {},
        created() {
            this.id = this.$route.query.type
            this.getList();
        },
        methods: {
            search() {
                this.queryForm.currentPage = 1;
                this.getList();
            },
            // 获取项目列表
            getList() {
                let that = this
                let data = {
                    heritage_category_id: that.id,
                    title: that.queryForm.search,
                    type: '',
                    page: that.queryForm.currentPage,
                    limit: 12,
                    recommend: ''
                }
                heritageList(data).then((response) => {
                    that.dataList = response.data.list
                    that.total = response.data.count
                });
            },
            // 查看详情
            handleDetail(v) {
                this.$router.push({
                    path: "/cultural/inheritDetails",
                    query: {
                        id: v.id,
                    },
                });
            },
            // 切换页数
            changePage(page) {
                this.queryForm.currentPage = page;
                this.getList();
            },
        },
    };
</script>

<style lang="scss" scoped>
    .inherit {
        width: 892px;
        min-height: 200px;
        margin: auto;

        .inherit-top {
            width: 100%;
            border-radius: 8px;
            padding: 20px;
            box-sizing: border-box;
            background-color: #fff;
            box-shadow: 0 0 10px rgba(217, 217, 217, 0.3);

            .row {
                min-height: 36px;
                width: 100%;
                margin-top: 15px;

                &-title {
                    width: 90px;
                    color: #909090;
                    font-size: 14px;
                }
            }
        }

        .inherit-bottom {
            width: 100%;
            border-radius: 0 8px 8px 8px;
            padding: 20px;
            box-sizing: border-box;
            background-color: #fff;
            box-shadow: 0 0 10px rgba(217, 217, 217, 0.3);

            .inherit-box {
                width: 100%;

                .person-item {
                    width: 416px;
                    height: 190px;
                    position: relative;

                    &:nth-child(2n-1) {
                        margin-right: 20px;
                    }

                    .person-bg {
                        width: 100%;
                        height: 144px;
                        transition: all 0.5s;
                        box-shadow: 0 0 15px 0 rgba(225, 225, 225, 0.51);
                        position: relative;

                        .person-name {
                            position: absolute;
                            width: 226px;
                            top: 15px;
                            right: 15px;
                            font-size: 16px;
                            color: #313131;
                            font-weight: 600;
                        }

                        .person-describe {
                            position: absolute;
                            width: 226px;
                            top: 47px;
                            right: 15px;
                            font-size: 14px;
                            color: #313131;
                            line-height: 26px;
                        }
                    }

                    .photo {
                        position: absolute;
                        top: 15px;
                        left: 15px;
                        width: 144px;
                        height: 184px;
                        z-index: 5;
                        transition: all 0.5s;
                        box-shadow: 5px 5px 4px 0px rgba(0, 0, 0, 0.25);
                    }

                    &:hover {
                        cursor: pointer;

                        .person-bg {
                            box-shadow: 0px 0px 15px 0px rgba(128, 128, 128, 0.51);
                        }

                        .photo {
                            box-shadow: 5px 5px 4px 0px rgba(81, 81, 81, 0.5);
                        }
                    }
                }
            }
        }
    }
</style>